home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / Xm / XmPrintShell.z / XmPrintShell
Encoding:
Text File  |  2002-10-03  |  20.5 KB  |  397 lines

  1.  
  2.  
  3.  
  4.      XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))          UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV          XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll - a shell widget class used for printing in
  10.           Motif
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.           #include <Xm/Print.h>
  14.           BBBBoooooooolllleeeeaaaannnn XXXXmmmmIIIIssssPPPPrrrriiiinnnnttttSSSShhhheeeellllllll(
  15.           WWWWiiiiddddggggeeeetttt);
  16.  
  17.      VVVVEEEERRRRSSSSIIIIOOOONNNN
  18.           This page documents Motif 2.1.
  19.  
  20.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  21.           The XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllllprovides the Motif application programmer
  22.           with an Xt widget oriented API to some of the X Print
  23.           resources and a callback to drive the pagination.
  24.  
  25.           The XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllllprovides a simple callback to handle the
  26.           pagination logic, and a set of resources to get and set
  27.           common printer attributes.
  28.  
  29.           If not created on an XXXXPPPPrrrriiiinnnnttttconnection, XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllllbehaves
  30.           as a regular applicationShell.
  31.  
  32.           The XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllllalso initializes the XXXXpppp extension event
  33.           handling mechanism, by registering an extension selector
  34.           that calls XXXXppppSSSSeeeelllleeeeccccttttIIIInnnnppppuuuuttttand event dispatcher for print and
  35.           attributes XXXXpppp events, so applications can use
  36.           XXXXttttIIIInnnnsssseeeerrrrttttEEEEvvvveeeennnnttttTTTTyyyyppppeeeeHHHHaaaannnnddddlllleeeerrrrto register their own handler with
  37.           the XXXXpppp events.
  38.  
  39.         AAAArrrrgggguuuummmmeeeennnnttttssss
  40.           No XXXXmmmmCCCCrrrreeeeaaaatttteeee function is provided, since this is a toplevel
  41.           shell, most likely created thru some XXXXttttshell creation
  42.           routine or XXXXmmmmPPPPrrrriiiinnnnttttSSSSeeeettttuuuupppp.
  43.  
  44.         CCCCllllaaaasssssssseeeessss
  45.           XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll is a subclass of AAAApppppppplllliiiiccccaaaattttiiiioooonnnnSSSShhhheeeellllllll; it inherits
  46.           behavior, resources and traits from all its superclasses.
  47.           The class pointer is _X_m_P_r_i_n_t_S_h_e_l_l_W_i_d_g_e_t_C_l_a_s_s.
  48.  
  49.         NNNNeeeewwww RRRReeeessssoooouuuurrrrcccceeeessss
  50.                                            XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll RRRReeeessssoooouuuurrrrcccceeee SSSSeeeetttt
  51.           NNNNaaaammmmeeee                         CCCCllllaaaassssssss                        TTTTyyyyppppeeee             DDDDeeeeffffaaaauuuulllltttt   AAAAcccccccceeeessssssss
  52.           _X_m_N_s_t_a_r_t_J_o_b_C_a_l_l_b_a_c_k          _X_m_C_C_a_l_l_b_a_c_k                  _X_t_C_a_l_l_b_a_c_k_L_i_s_t   _N_U_L_L      CCCCSSSSGGGG
  53.           _X_m_N_e_n_d_J_o_b_C_a_l_l_b_a_c_k            _X_m_C_C_a_l_l_b_a_c_k                  _X_t_C_a_l_l_b_a_c_k_L_i_s_t   _N_U_L_L      CCCCSSSSGGGG
  54.           _X_m_N_p_a_g_e_S_e_t_u_p_C_a_l_l_b_a_c_k         _X_m_C_C_a_l_l_b_a_c_k                  _X_t_C_a_l_l_b_a_c_k_L_i_s_t   _N_U_L_L      CCCCSSSSGGGG
  55.           _X_m_N_m_i_n_X                      _X_m_C_M_i_n_X                      DDDDiiiimmmmeeeennnnssssiiiioooonnnn        ddddyyyynnnnaaaammmmiiiicccc   GGGG
  56.           _X_m_N_m_i_n_Y                      _X_m_C_M_i_n_Y                      DDDDiiiimmmmeeeennnnssssiiiioooonnnn        ddddyyyynnnnaaaammmmiiiicccc   GGGG
  57.           _X_m_N_m_a_x_X                      _X_m_C_M_a_x_X                      DDDDiiiimmmmeeeennnnssssiiiioooonnnn        ddddyyyynnnnaaaammmmiiiicccc   GGGG
  58.  
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 10/3/02)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))          UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV          XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))
  71.  
  72.  
  73.  
  74.           _X_m_N_m_a_x_Y                      _X_m_C_M_a_x_Y                      DDDDiiiimmmmeeeennnnssssiiiioooonnnn        ddddyyyynnnnaaaammmmiiiicccc   GGGG
  75.           _X_m_N_d_e_f_a_u_l_t_P_i_x_m_a_p_R_e_s_o_l_u_t_i_o_n   _X_m_C_D_e_f_a_u_l_t_P_i_x_m_a_p_R_e_s_o_l_u_t_i_o_n   uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt   111100000000       CCCCSSSSGGGG
  76.           _X_m_N_p_d_m_N_o_t_i_f_i_c_a_t_i_o_n_C_a_l_l_b_a_c_k   _X_m_C_C_a_l_l_b_a_c_k                  _X_t_C_a_l_l_b_a_c_k_L_i_s_t   _N_U_L_L      CCCCSSSSGGGG
  77.  
  78.           _X_m_N_s_t_a_r_t_J_o_b_C_a_l_l_b_a_c_k
  79.                     Specifies the callback driving the beginning of
  80.                     rendering.  It is safe for an application to start
  81.                     rendering after this callback has been activated.
  82.                     XXXXppppSSSSttttaaaarrrrttttJJJJoooobbbbmust be called to trigger this callback.
  83.  
  84.           _X_m_N_e_n_d_J_o_b_C_a_l_l_b_a_c_k
  85.                     Specifies the callback driving the end of
  86.                     rendering.  Notify the client that all rendering
  87.                     has been processed (whether on print-to-file or
  88.                     regular spool).  XXXXppppEEEEnnnnddddJJJJoooobbbbis called by the print
  89.                     shell to trigger this callback.
  90.  
  91.           _X_m_N_p_a_g_e_S_e_t_u_p_C_a_l_l_b_a_c_k
  92.                     Specifies the callback driving the page layout. It
  93.                     is safe for an app to start rendering from this
  94.                     callback even if the XXXXmmmmNNNNssssttttaaaarrrrttttJJJJoooobbbbCCCCaaaallllllllbbbbaaaacccckkkkis not
  95.                     used.
  96.  
  97.           _X_m_N_m_i_n_X, _X_m_N_m_i_n_Y, _X_m_N_m_a_x_X, _X_m_N_m_a_x_Y
  98.                     Specify the imageable area of the page in the
  99.                     current print context. XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll also maintains
  100.                     a proper size at all times by updating its own
  101.                     widget dimension whenever an attribute, such as
  102.                     resolution or orientation, changes. It is sized in
  103.                     its IIIInnnniiiittttiiiiaaaalllliiiizzzzeeee routine so that the application can
  104.                     rely on a proper size before the first SSSSttttaaaarrrrttttPPPPaaaaggggeeee
  105.                     call is issued.
  106.  
  107.           _X_m_N_d_e_f_a_u_l_t_P_i_x_m_a_p_R_e_s_o_l_u_t_i_o_n
  108.                     Indicates the resolution in dpi (dot per inch) of
  109.                     the image files read and converted by Motif for
  110.                     the widget descendants of this shell. It is used
  111.                     to determine a scaling ratio to be applied to
  112.                     pixmap created thru regular pixmap/icon conversion
  113.                     of the following Widget resources:
  114.  
  115.                        +o  _X_m_L_a_b_e_l.label*Pixmap, _X_m_I_c_o_n_G.*IconPixmap
  116.                           _X_m_T_o_g_g_l_e_B.selectPixmap, _X_m_P_u_s_h_B_G.armPixmap,
  117.                           _X_m_I_c_o_n_G.*IconMask,
  118.                           _X_m_M_e_s_s_a_g_e_B_o_x.symbolPixmap,
  119.                           _X_m_C_o_n_t_a_i_n_e_r.*StatePixmap, ...
  120.  
  121.                        +o  Leaving out the pixmap resources being used
  122.                           for tiling (XmNhighlightPixmap,
  123.                           XmNtopShadowPixmap, XmNbottomShadowPixmap,
  124.                           XmNbackgroundPixmap, ...)
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 10/3/02)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))          UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV          XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))
  137.  
  138.  
  139.  
  140.           _X_m_N_p_d_m_N_o_t_i_f_i_c_a_t_i_o_n_C_a_l_l_b_a_c_k
  141.                     A callback notifying the application about the
  142.                     status of the PDM (see XmPrintPopupPDM). A
  143.                     XmPrintShellCallbackStruct is used, with reason:
  144.  
  145.                        +o  _X_m_C_R__P_D_M__N_O_N_E: no PDM available on this
  146.                           display for the named selection (provided in
  147.                           detail)
  148.  
  149.                        +o  _X_m_C_R__P_D_M__S_T_A_R_T__V_X_A_U_T_H: the PDM is not
  150.                           authorized to connect to the video display.
  151.  
  152.                        +o  _X_m_C_R__P_D_M__S_T_A_R_T__P_X_A_U_T_H: the PDM is not
  153.                           authorized to connect to the print display.
  154.  
  155.                        +o  _X_m_C_R__P_D_M__U_P: the PDM is up and running
  156.  
  157.                        +o  _X_m_C_R__P_D_M__O_K: the PDM has exited with OK
  158.                           status
  159.  
  160.                        +o  _X_m_C_R__P_D_M__C_A_N_C_E_L: the PDM has exited with
  161.                           CANCEL
  162.  
  163.                        +o  _X_m_C_R__P_D_M__S_T_A_R_T__E_R_R_O_R: the PDM cannot start
  164.                           due to some error (usually logged)
  165.  
  166.                        +o  _X_m_C_R__P_D_M__E_X_I_T__E_R_R_O_R: the PDM has exited with
  167.                           an error
  168.  
  169.         CCCCaaaallllllllbbbbaaaacccckkkk IIIInnnnffffoooorrrrmmmmaaaattttiiiioooonnnn
  170.           The XXXXmmmmNNNNssssttttaaaarrrrttttJJJJoooobbbbCCCCaaaallllllllbbbbaaaacccckkkk,
  171.           XXXXmmmmNNNNeeeennnnddddJJJJoooobbbbCCCCaaaallllllllbbbbaaaacccckkkk,,,,XXXXmmmmNNNNppppaaaaggggeeeeSSSSeeeettttuuuuppppCCCCaaaallllllllbbbbaaaacccckkkk and
  172.           XXXXmmmmNNNNppppddddmmmmNNNNoooottttiiiiffffiiiiccccaaaattttiiiioooonnnnCCCCaaaallllllllbbbbaaaacccckkkkoperate on a
  173.           _X_m_P_r_i_n_t_S_h_e_l_l_C_a_l_l_b_a_c_k_S_t_r_u_c_t, which is defined as follow:
  174.  
  175.           typedef struct
  176.           {
  177.               int     reason;  /* XmCR_START_JOB, XmCR_END_JOB,
  178.                                   XmCR_PAGE_SETUP, XmCR_PDM_* */
  179.               XEvent  *event;
  180.               XPContext print_context;
  181.               Boolean last_page; /* in_out */
  182.               XtPointer detail;
  183.           } XmPrintShellCallbackStruct;
  184.  
  185.         AAAAddddddddiiiittttiiiioooonnnnaaaallll BBBBeeeehhhhaaaavvvviiiioooorrrr
  186.           The _l_a_s_t__p_a_g_e field is only meaningful when the reason is
  187.           _X_m_C_R__P_A_G_E__S_E_T_U_P.
  188.  
  189.           The page setup callback is called with _l_a_s_t__p_a_g_e FFFFaaaallllsssseeee to
  190.           notify the application that it has to get its internal
  191.           layout state ready for the next page. Typically, a widget
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 10/3/02)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))          UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV          XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))
  203.  
  204.  
  205.  
  206.           based application will change the content of a LLLLaaaabbbbeeeellll showing
  207.           the page number, or scroll the content of the TTTTeeeexxxxtttt widget.
  208.  
  209.           When the application has processed its last page, it should
  210.           set the _l_a_s_t__p_a_g_e field in the callback struct to TTTTrrrruuuueeee. The
  211.           callback will be called a last time after that with
  212.           _l_a_s_t__p_a_g_eFFFFaaaallllsssseeee to notify the application that it can safely
  213.           clean-up its internal state (e.g., destroy widgets).
  214.  
  215.           No drawing should occur from within the callback function in
  216.           the application, this is an Exposure event-driven
  217.           programming model where widgets render themselves from their
  218.           expose methods.
  219.  
  220.           The print shell calls XXXXppppSSSSttttaaaarrrrttttPPPPaaaaggggeeee after the
  221.           ppppaaaaggggeeeeSSSSeeeettttuuuuppppCCCCaaaallllllllbbbbaaaacccckkkk returns, and XXXXppppEEEEnnnnddddPPPPaaaaggggeeeeupon reception of
  222.           SSSSttttaaaarrrrttttPPPPaaaaggggeeeeNNNNoooottttiiiiffffyyyy.
  223.  
  224.      EEEERRRRRRRROOOORRRRSSSS////WWWWAAAARRRRNNNNIIIINNNNGGGGSSSS
  225.           _X_m_P_r_i_n_t_S_h_e_l_l can generate the following warnings:
  226.  
  227.              +o  NNNNooootttt ccccoooonnnnnnnneeeecccctttteeeedddd ttttoooo aaaa vvvvaaaalllliiiidddd XXXX PPPPrrrriiiinnnntttt SSSSeeeerrrrvvvveeeerrrr:::: bbbbeeeehhhhaaaavvvviiiioooorrrr
  228.                 uuuunnnnddddeeeeffffiiiinnnneeeedddd....
  229.  
  230.              +o  AAAAtttttttteeeemmmmpppptttt ttttoooo sssseeeetttt aaaannnn iiiinnnnvvvvaaaalllliiiidddd rrrreeeessssoooolllluuuuttttiiiioooonnnn oooonnnn aaaa pppprrrriiiinnnntttteeeerrrr:::: %%%%ssss
  231.  
  232.              +o  AAAAtttttttteeeemmmmpppptttt ttttoooo sssseeeetttt aaaannnn iiiinnnnvvvvaaaalllliiiidddd oooorrrriiiieeeennnnttttaaaattttiiiioooonnnn oooonnnn aaaa pppprrrriiiinnnntttteeeerrrr:::: %%%%ssss
  233.  
  234.      RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
  235.           Not applicable
  236.  
  237.      EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  238.           PrintOnePageCB(Widget pshell, XtPointer npages,
  239.           /*----------*/ XmPrintSetPageCBStruct psp)
  240.           {
  241.               static int cur_page = 0;
  242.               cur_page++;
  243.  
  244.               if (! psp->last_page
  245.                   && curPage > 1) /* no need to scroll for the first page */
  246.               {
  247.  
  248.                   XmTextScroll(ptext, prows);  /* get ready for next page */
  249.  
  250.               } else {    /**** I'm done */
  251.  
  252.                  XtDestroyWidget(pshell);
  253.                  XtCloseDisplay(XtDisplay(pshell));
  254.               }
  255.  
  256.               if (cur_page == (int) n_pages) psp->last_page = True;
  257.           }
  258.  
  259.  
  260.  
  261.      Page 4                                          (printed 10/3/02)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))          UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV          XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))
  269.  
  270.  
  271.  
  272.           PrintOKCallback(...)
  273.           /*-------------*/
  274.           {
  275.               pshell = XmPrintSetup (widget, pbs->print_screen,
  276.                                              "Print", NULL, 0);
  277.  
  278.               XpStartJob(XtDisplay(pshell), XPSpool);
  279.  
  280.               /**** here I get the size of the shell, create my widget
  281.                     hierarchy: a bulleting board, and then a text widget,
  282.                     that I stuff with the video text widget buffer */
  283.  
  284.               /* get the total number of pages to print */
  285.               /* same code as previous example to get n_pages */
  286.  
  287.               /****  set up my print callback */
  288.               XtAddCallback(pshell,  XmNpageSetUpCallback,
  289.                                      PrintOnePageCB, n_pages);
  290.           }
  291.  
  292.           Examples of XXXXmmmmNNNNddddeeeeffffaaaauuuullllttttPPPPiiiixxxxmmmmaaaappppRRRReeeessssoooolllluuuuttttiiiioooonnnn usage:
  293.  
  294.              +o  An application reuses the same image sources it uses
  295.                 for the video interface, in XBM or XPM, to layout on
  296.                 its printed pages. In this case, scaling is seamless.
  297.  
  298.               ! icon.xpm is 30x30 pixels
  299.               app*dialog.pushb.labelPixmap:icon.xpm
  300.               ! print is 400dpi
  301.               app.print*form.lab.labelPixmap:icon.xpm
  302.               ! 120x120 pixels on the paper (auto scaling)
  303.  
  304.              +o  An application provides a new set of image files, for
  305.                 a given printer resolution (say 300). It doesn't want
  306.                 automatic scaling by the toolkit for that resolution,
  307.                 it wants scaling based on these 300dpi images for
  308.                 higher resolution. It creates its print shell inside
  309.                 using the name "printHiRes" and adds the following in
  310.                 its resource file:
  311.  
  312.               app.printHiRes.defaultPixmapResolution:300
  313.               ! icon300.xpm is 120x120 pixels
  314.               app.printHiRes*form.lab.labelPixmap:icon300.xpm
  315.               ! 120x120 pixels on the paper (no scaling)
  316.  
  317.           This way a printer resolution of 600 will result in a scale
  318.           of a 300 dpi image by 2 (dpi=600 divided by base=300), while
  319.           a printer resolution of 150 (using default print shell name
  320.           "print") will use the 100 dpi icon scaled by 1.5 (dpi=150
  321.           divided by default base=100).
  322.  
  323.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  324.  
  325.  
  326.  
  327.      PPPPaaaaggggeeee 5555                                          ((((pppprrrriiiinnnntttteeeedddd 11110000////3333////00002222))))
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))          UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV          XXXXmmmmPPPPrrrriiiinnnnttttSSSShhhheeeellllllll((((3333XXXX))))
  335.  
  336.  
  337.  
  338.           XXXXmmmmPPPPrrrriiiinnnnttttSSSSeeeettttuuuupppp(3), XXXXmmmmRRRReeeeddddiiiissssppppllllaaaayyyyWWWWiiiiddddggggeeeetttt(3), XXXXmmmmPPPPrrrriiiinnnnttttTTTTooooFFFFiiiilllleeee(3),
  339.           XXXXmmmmPPPPrrrriiiinnnnttttPPPPooooppppuuuuppppPPPPDDDDMMMM(3)
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                                          (printed 10/3/02)
  394.  
  395.  
  396.  
  397.